package edu.uwg.LewisWilliams.android.assignment1;

import edu.uwg.LewisWilliams.android.assignment1.R;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
/**
 * HelloActivity displays a message to the user using the user's name
 * that was entered on a previous activity.
 * 
 * @author Charles Williams
 * @version 2011.9.9
 */
public class HelloActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        String userName;
        
        //Checks to see if the information was passed from the previous activity
        if(this.getIntent().getExtras()!= null){
        	Bundle transferedData = this.getIntent().getExtras();
        	
        	//If the field is left blank the person is called a stranger
        	if(transferedData.getString("userName").equalsIgnoreCase("")){
        		userName = "Stranger";
        	}
        	
        	//Else they are called by the name that was in the text field
        	else{
        		userName = transferedData.getString("userName");
        	}
        	
        	//Finds and retrieves the text view
        	TextView greeting = (TextView) this.findViewById(R.id.greeting);
        	//Sets the text view text
        	greeting.setText("Hello " + userName + "!");
        }  
    }
}